package com.gukun.springboot.tdengine.util;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;

/**
 * @author zhang
 */
public class SignatureUtil {
    public static String generateSignature(String data,String secretKey) throws Exception{
        Mac sha256 = Mac.getInstance("HmacSHA256");
        SecretKeySpec spec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256");
        sha256.init(spec);
        byte[] sign = sha256.doFinal(data.getBytes());
        return Base64.getEncoder().encodeToString(sign);
    }
}
